package com.dongdongshop.service.impl;

import com.dongdongshop.mapper.TbAreasMapper;
import com.dongdongshop.mapper.TbCitiesMapper;
import com.dongdongshop.mapper.TbProvincesMapper;
import com.dongdongshop.pojo.*;
import com.dongdongshop.service.CityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@com.alibaba.dubbo.config.annotation.Service
public class CityServiceImpl implements CityService {

    @Autowired
    private TbProvincesMapper tbProvincesMapper;

    @Autowired
    private TbAreasMapper tbAreasMapper;

    @Autowired
    private TbCitiesMapper tbCitiesMapper;
    @Override
    public List<TbProvinces> selectProvinces() {
        List<TbProvinces> tbProvinces = tbProvincesMapper.selectByExample(null);
        return tbProvinces;
    }

    @Override
    public List<TbCities> selectCities() {
        List<TbCities> tbCities = tbCitiesMapper.selectByExample(null);
        return tbCities;
    }

    @Override
    public List<TbAreas> selectAreas() {
        List<TbAreas> tbAreas = tbAreasMapper.selectByExample(null);
        return tbAreas;
    }

    @Override
    public List<TbCities> selectCitiesById(String id) {
        TbCitiesExample example = new TbCitiesExample();
        TbCitiesExample.Criteria criteria = example.createCriteria();
        criteria.andProvinceidEqualTo(id);
        return tbCitiesMapper.selectByExample(example);
    }

    @Override
    public List<TbAreas> selectAreasById(String id) {
        TbAreasExample example = new TbAreasExample();
        TbAreasExample.Criteria criteria = example.createCriteria();
        criteria.andCityidEqualTo(id);
        return tbAreasMapper.selectByExample(example);
    }
}
